<template>
  <div>
    <FormPanel ref="from" :list="formList" :formType="type" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
    <BreakSpace label="操作记录" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable ref="table" :isSelectColumn="false" height="auto" :columns="columns" :dataSource="tableLists" :onColumnsChange="columns => (this.columns = columns)"> </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <el-button @click="closeDrawer">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { queryDetailById, queryLog } from '@/api/omFinance/FinanceManage/FinanceQuery';

export default {
  mixins: [dictionary],
  props: ['type', 'rowData'],
  data() {
    return {
      formList: this.createdFrom(),
      columns: this.createdTable(),
      fetchParams: {},
      fetchApi: () => {},
      formData: {},
      infoVisible: false,
      tableLists: []
    };
  },
  mounted() {
    this.getDetail();
    // this.getUser();
  },
  methods: {
    async getDetail() {
      const res = await queryDetailById(this.rowData.id);
      const res1 = await queryLog(this.rowData.id);
      if (res.resultCode == 200) {
        res.data.isRiskDealer = Number(res.data.isRiskDealer) || '';
        this.formList.forEach(x => {
          x.initialValue = res.data[x.fieldName];
        });
      }
      if (res1.resultCode == 200) {
        this.tableLists = res1.data;
      }
    },

    changeHandle(val) {},
    closeDrawer() {
      this.$emit('close', false, '');
    },
    createdFrom() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '三方融资'
        },
        {
          type: 'INPUT',
          label: '申请单号',
          fieldName: 'applyNo',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '银行名称',
          fieldName: 'bankName',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '出票金额（万）',
          fieldName: 'billAmount',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '出票期限',
          fieldName: 'billDeadline',
          placeholder: '',
          itemList: this.createDictList('6027')
        },
        {
          type: 'INPUT',
          label: '银行联系人',
          fieldName: 'linkMan',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '银行联系电话',
          fieldName: 'linkPhone',
          placeholder: ''
        },
        {
          type: 'DATE',
          label: '申请日期',
          fieldName: 'applyDate',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '经销商代码',
          fieldName: 'ownerCode',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'dealerName',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '申请类型',
          fieldName: 'applyType',
          placeholder: '请选择',
          itemList: this.createDictList('6073')
        },
        {
          type: 'INPUT',
          label: '提车公司',
          fieldName: 'salesCompanyName',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '收款方',
          offsetRightCols: 1,
          fieldName: 'payee',
          placeholder: '',
          itemList: this.createDictList('6031')
        },
        {
          type: 'INPUT',
          label: '预提车型',
          selfCols: 2,
          fieldName: 'reservedModel',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '备注',
          fieldName: 'applyRemark',
          selfCols: 3,
          placeholder: ''
        },
        {
          type: 'BREAK_SPACE',
          label: '审批参数'
        },
        {
          type: 'INPUT',
          label: '本月已开票金额',
          fieldName: 'invoiceAmount',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '上月终端',
          fieldName: 'lastSalesQuantity',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '前三月平均终端',
          fieldName: 'averageSalesQuantity',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '当前库存数',
          fieldName: 'stockQuantity',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '库存系数',
          fieldName: 'stockFactor',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '库存系数上限',
          fieldName: 'stockFactorLimit',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '目前库销比',
          fieldName: 'stockSalesRatio',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '超期车台数',
          fieldName: 'overdueQuantity',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '是否风险关注店',
          fieldName: 'isRiskDealer',
          placeholder: '',
          itemList: this.createDictList('1004')
        },
        {
          type: 'INPUT',
          label: '移动比例',
          fieldName: 'moveRatio',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '回款率',
          fieldName: 'collectionRate',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '经销商经营状态',
          fieldName: 'dealerStatus',
          placeholder: '',
          itemList: this.createDictList('2552')
        },
        {
          type: 'INPUT',
          label: '审批意见',
          fieldName: 'headCheckRemark',
          selfCols: 3,
          placeholder: ''
        }
      ];
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作状态',
          dataIndex: 'businessStatus',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('6030'),
          render: p => {
            return <span>{this.createDictText(p.row.businessStatus, '6030')}</span>;
          }
        },
        {
          title: '操作人员',
          dataIndex: 'createdByName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '操作时间',
          dataIndex: 'createdAt',
          sorter: true,
          filter: true,
          filterType: 'date-range'
        },
        {
          title: '审核备注',
          dataIndex: 'remark',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    }
  }
};
</script>
